home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE08 / DATADICT / APPSUPRT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-10-19  |  3.4 KB  |  119 lines

  1. unit Appsuprt;
  2.  
  3. interface
  4. uses DB;
  5. const
  6.     FieldTypeStr : array[ftunknown..ftgraphic] of string[8] =
  7.       ('Unknown', 'String', 'Smallint', 'Integer', 'Word',
  8.        'Boolean', 'Float', 'Currency', 'BCD', 'Date', 'Time',
  9.        'DateTime', 'Bytes', 'VarBytes', 'Blob', 'Memo', 'Graphic');
  10.     FieldTypeLtr : array[ftunknown..ftgraphic] of string[1] =
  11.       ('U', 'S', 'i', 'I', 'W',
  12.        'L', 'F', 'C', 'B', 'D', 'T',
  13.        'A', 'y', 'V', 'o', 'M', 'G');
  14.  
  15.  
  16. type
  17.   PFieldDef = ^FieldDefRecType;
  18.   FieldDefRecType = record
  19.       fieldname : string[20];
  20.       scrprompt : string[20]; {tfield.DisplayName}
  21.       scrformat : string[20]; {tfield.DisplayText -- an editmask}
  22.       grdprompt : string[10];
  23.       grdwidth  : integer;    {tfield.DisplayWidth}
  24.       fldtype   : string[1];  {FieldTypeLtr}
  25.       fldlen    : integer;    {tfield.size}
  26.       flddec    : integer;
  27.       fldidx    : boolean;
  28.       idxexp    : string;
  29.       taborder  : integer;
  30.       required  : boolean;    {tfield.required}
  31.       default   : string[80];
  32.       editmask  : string[80]; {tfield.editMask}
  33.       validvalue : pchar;
  34.           {for numerics: minvalue, maxvalue}
  35.           {for strings: comma delimited list}
  36.       hint      : string;
  37.       helpid    : longint;
  38.       haslink   : boolean;
  39.       srclinktbl : string[20];
  40.       srclinkfld : string[20];
  41.       iscalc     : boolean;
  42.       next, prev : pFieldDef;
  43.       end;
  44.  
  45.     PtableDef = ^TableDefRecType;
  46.     TableDefRecType = record
  47.       Query     : tQuery;
  48.       tablename : string[20];
  49.       fieldDefs : PFieldDef;
  50.       next, prev : PTableDef;
  51.       end;
  52.  
  53.  
  54.     TDBdict = class(tobject);
  55.       TableDef : PTableDef;
  56.       procedure FillTableDef(dict : tdatasource);
  57.       end;
  58.  
  59. var
  60.   DBdict : TDBdict;
  61.  
  62. implementation
  63.  
  64. procedure TdbDict.FillTableDef(dict : tdatasource);
  65. begin
  66.   query.dataSource := Dict;
  67.   query.databasename := dict.databasename;
  68.   query.close;
  69.   query.sql.clear;
  70.   query.params.clear;
  71.   sqlstr := 'SELECT * FROM '+DDTableName;
  72.     query.sql.add(sqlstr);
  73.     query.prepare;
  74.     query.open;
  75.     query.first;
  76.     { get tablenames in data dictionary, stick in M_tableList lines}
  77.     if query.findfield('TABLE_NAME') = nil
  78.       then begin
  79.          cursor := crDefault;
  80.          MessageDlg(DDListBox.items[whichone]+#13+'is not a Data Dictionary Database.', mtInformation, [mbOK], 0);
  81.          m_status.hide;
  82.          result := ExistButNotDD;
  83.          exit;
  84.          end;
  85.     m_tableList.lines.add(query.findfield('TABLE_NAME').text);  {get first one}
  86.     inc(numfields);
  87.     query.next;
  88.     while not query.eof do begin
  89.       tablefound := false;
  90.       thistable := query.findfield('TABLE_NAME').text;
  91.       inc(numFields);
  92.       for tablenum := 0 to m_tablelist.lines.count - 1 do
  93.         if m_tableList.lines[tablenum] = thistable
  94.            then begin
  95.               tablefound := true;
  96.               break;
  97.               end;
  98.         {done looking for thistable}
  99.       if not tablefound
  100.         then  m_tablelist.lines.add(thistable);
  101.       query.next;
  102.       end; {while searching for table names}
  103.   except
  104.      on EdataBaseError do begin
  105.        cursor := crDefault;
  106.        MessageDlg('Not a data base file or other DB error', mtInformation, [mbOK], 0);
  107.        l_size.caption := '';
  108.        l_update.caption := '';
  109.        m_status.hide;
  110.        result := ExistbutnotDD;
  111.        end;
  112.      end; {of exceptions}
  113.  
  114.  
  115.  
  116.  
  117.  
  118. end.
  119.